package com.xinqing.bigdata.rdd

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
  * @Author:CHQ
  * @Date:2020 /6/19 19:21
  * @Description
  */
object MapTransform_2 {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local[*]").setAppName("create RDD")
    val sc = new SparkContext(conf)
    val intRDD: RDD[Int] = sc.makeRDD(1 to 10)

    //针对分区，批处理数据
    val mapPartitionsRDD: RDD[Int] = intRDD.mapPartitions({
      datas => datas.map(_ * 2)
    })
    mapPartitionsRDD.collect().foreach(println)
  }
}
